<%-- 通用表单页面添加--%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/views/common/taglibs.jsp" %>

<form class="form-horizontal" role="form" id="entity_form" method="post" action="${ctx}/${saveUrl}" enctype="multipart/form-data">
    <input type="hidden" name="entityId" value="${entityId}">
    <c:forEach items="${fieldRecords}" var="data" varStatus="v">
        <c:choose>
            <c:when test="${v.index%2 == 0}">
                <div class="row">
                    <c:choose>
                        <c:when test="${fn:endsWith(data.fieldRecord.name,'_decimal') || fn:endsWith(data.fieldRecord.name,'_precent') || fn:endsWith(data.fieldRecord.name,'_currency')}">
                            <div class="col-lg-5 col-md-5">
                                <div class="form-group">
                                    <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}:<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                    <div class="col-lg-9 col-md-9">
                                        <input type="number" class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}" placeholder="请输入数值">
                                    </div>
                                </div>
                            </div>
                        </c:when>
                        <c:when test="${fn:endsWith(data.fieldRecord.name,'_date')}">
                            <div class="col-lg-5 col-md-5">
                                <div class="form-group">
                                    <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}:<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                    <div class="col-lg-9 col-md-9">
                                        <input type="text" class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}" readonly placeholder="请选择日期" onclick="showDateTime('${data.fieldRecord.name}','yyyy-mm-dd',2);"/>
                                    </div>
                                </div>
                            </div>
                        </c:when>
                        <c:when test="${fn:endsWith(data.fieldRecord.name,'_datetime')}">
                            <div class="col-lg-5 col-md-5">
                                <div class="form-group">
                                    <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}:<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                    <div class="col-lg-9 col-md-9">
                                        <input type="text" class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}" readonly placeholder="请选择日期时间" onclick="showDateTime('${data.fieldRecord.name}','yyyy-mm-dd hh:ii:ss',0);"/>
                                    </div>
                                </div>
                            </div>
                        </c:when>
                        <c:when test="${fn:endsWith(data.fieldRecord.name,'_textarea') || fn:endsWith(data.fieldRecord.name,'_textblock')}">
                            <div class="col-lg-5 col-md-5">
                                <div class="form-group">
                                    <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}：<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                    <div class="col-lg-9 col-md-9">
                                        <textarea class="form-control" rows="2" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}"></textarea>
                                    </div>
                                </div>
                            </div>
                        </c:when>
                        <c:when test="${fn:endsWith(data.fieldRecord.name,'_singlebox') || fn:endsWith(data.fieldRecord.name,'_radio')}">
                            <div class="col-lg-5 col-md-5">
                                <div class="form-group">
                                    <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}: <c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                    <div class="col-lg-9 col-md-9">
                                        <select class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}" selfid="${data.fieldRecord.id}" ifcascadeid="${data.fieldRecord.ifcascade}" onchange='chageEnumSelectBoxValue(this)'>
                                            <option value="">--请选择--</option>
                                            <c:forEach items="${data.datas}" var="selectData">
                                                <option <c:if test="${!empty selectData.resoptionid}"> resoptionid="${selectData.resoptionid}" style="display: none" </c:if> value="${selectData.id}">${selectData.name}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </c:when>
                        <c:when test="${fn:endsWith(data.fieldRecord.name,'_bit')}">
                            <div class="col-lg-5 col-md-5">
                                <div class="form-group">
                                    <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}: <c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                    <div class="col-lg-9 col-md-9">
                                        <select class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}">
                                            <option value="">--请选择--</option>
                                            <option value="0">否</option>
                                            <option value="1">是</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </c:when>
                        <c:when test="${fn:endsWith(data.fieldRecord.name,'_mutibox')}">
                            <div class="col-lg-5 col-md-5">
                                <div class="form-group">
                                    <label for="${data.fieldRecord.name}_select" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}：<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                    <div class="col-lg-9 col-md-9">
                                        <input type="hidden" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}">
                                        <select id="${data.fieldRecord.name}_select" class="selectpicker form-control" multiple data-size="5" onchange="changeValue('${data.fieldRecord.name}_select', '${data.fieldRecord.name}');">
                                            <option selected value="">请选择</option>
                                            <c:forEach items="${data.datas}" var="selectData">
                                                <option value="${selectData.id}">${selectData.name}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </c:when>
                        <c:when test="${fn:endsWith(data.fieldRecord.name,'_img')}">
                            <div class="col-lg-5 col-md-5">
                                <div class="form-group">
                                    <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}：<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                    <div class="col-lg-9 col-md-9">
                                        <input type="file" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}">
                                    </div>
                                </div>
                            </div>
                        </c:when>
                        <c:when test="${fn:startsWith(data.fieldRecord.name,'pk_')}">
                            <div class="col-lg-5 col-md-5">
                                <div class="form-group">
                                    <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}：<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                    <div class="col-lg-9 col-md-9">
                                        <input type="hidden" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}" >
                                        <input type="input" class="form-control" id="t_${entityId}__${data.fieldRecord.name}_osv" valueinputid="t_${entityId}__${data.fieldRecord.name}"  onclick="parent.filterQuoteClick(this,false,false,null,null)">
                                    </div>
                                </div>
                            </div>
                        </c:when>
                        <c:otherwise>
                            <div class="col-lg-5 col-md-5">
                                <div class="form-group">
                                    <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}：<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                    <div class="col-lg-9 col-md-9">
                                        <input type="text" class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}">
                                    </div>
                                </div>
                            </div>
                        </c:otherwise>
                    </c:choose>
            </c:when>
            <c:otherwise>
                <c:choose>
                    <c:when test="${fn:endsWith(data.fieldRecord.name,'_decimal') || fn:endsWith(data.fieldRecord.name,'_precent') || fn:endsWith(data.fieldRecord.name,'_currency')}">
                        <div class="col-lg-5 col-md-5">
                            <div class="form-group">
                                <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}:<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                <div class="col-lg-9 col-md-9">
                                    <input type="number" class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}" placeholder="请输入数值">
                                </div>
                            </div>
                        </div>
                    </c:when>
                    <c:when test="${fn:endsWith(data.fieldRecord.name,'_date')}">
                        <div class="col-lg-5 col-md-5">
                            <div class="form-group">
                                <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}:<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                <div class="col-lg-9 col-md-9">
                                    <input type="text" class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}" readonly placeholder="请选择日期" onclick="showDateTime('${data.fieldRecord.name}','yyyy-mm-dd',2);"/>
                                </div>
                            </div>
                        </div>
                    </c:when>
                    <c:when test="${fn:endsWith(data.fieldRecord.name,'_datetime')}">
                        <div class="col-lg-5 col-md-5">
                            <div class="form-group">
                                <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}:<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                <div class="col-lg-9 col-md-9">
                                    <input type="text" class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}" readonly placeholder="请选择日期时间" onclick="showDateTime('${data.fieldRecord.name}','yyyy-mm-dd hh:ii:ss',0);"/>
                                </div>
                            </div>
                        </div>
                    </c:when>
                    <c:when test="${fn:endsWith(data.fieldRecord.name,'_textarea') || fn:endsWith(data.fieldRecord.name,'_textblock')}">
                        <div class="col-lg-5 col-md-5">
                            <div class="form-group">
                                <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}：<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                <div class="col-lg-9 col-md-9">
                                    <textarea class="form-control" rows="2" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}"></textarea>
                                </div>
                            </div>
                        </div>
                    </c:when>
                    <c:when test="${fn:endsWith(data.fieldRecord.name,'_singlebox') || fn:endsWith(data.fieldRecord.name,'_radio')}">
                        <div class="col-lg-5 col-md-5">
                            <div class="form-group">
                                <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}: <c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                <div class="col-lg-9 col-md-9">
                                    <select class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}" selfid="${data.fieldRecord.id}" ifcascadeid="${data.fieldRecord.ifcascade}" onchange='chageEnumSelectBoxValue(this)'>
                                        <option value="">--请选择--</option>
                                        <c:forEach items="${data.datas}" var="selectData">
                                            <option <c:if test="${!empty selectData.resoptionid}"> resoptionid="${selectData.resoptionid}" style="display: none" </c:if> value="${selectData.id}">${selectData.name}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </c:when>
                    <c:when test="${fn:endsWith(data.fieldRecord.name,'_bit')}">
                        <div class="col-lg-5 col-md-5">
                            <div class="form-group">
                                <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}: <c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                <div class="col-lg-9 col-md-9">
                                    <select class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}">
                                        <option value="">--请选择--</option>
                                        <option value="0">否</option>
                                        <option value="1">是</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </c:when>
                    <c:when test="${fn:endsWith(data.fieldRecord.name,'_mutibox')}">
                        <div class="col-lg-5 col-md-5">
                            <div class="form-group">
                                <label for="${data.fieldRecord.name}_select" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}：<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                <div class="col-lg-9 col-md-9">
                                    <input type="hidden" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}">
                                    <select id="${data.fieldRecord.name}_select" class="selectpicker form-control" multiple data-size="5" onchange="changeValue('${data.fieldRecord.name}_select', '${data.fieldRecord.name}');">
                                        <option selected value="">请选择</option>
                                        <c:forEach items="${data.datas}" var="selectData">
                                            <option value="${selectData.id}">${selectData.name}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </c:when>
                    <c:when test="${fn:endsWith(data.fieldRecord.name,'_img')}">
                        <div class="col-lg-5 col-md-5">
                            <div class="form-group">
                                <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}：<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                <div class="col-lg-9 col-md-9">
                                    <input type="file" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}">
                                </div>
                            </div>
                        </div>
                    </c:when>
                    <c:when test="${fn:startsWith(data.fieldRecord.name,'pk_')}">
                        <div class="col-lg-5 col-md-5">
                            <div class="form-group">
                                <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}：<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                <div class="col-lg-9 col-md-9">
                                    <input type="hidden" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}" >
                                    <input type="input" class="form-control" id="t_${entityId}__${data.fieldRecord.name}_osv" valueinputid="t_${entityId}__${data.fieldRecord.name}"  onclick="parent.filterQuoteClick(this,false,false,null,null)">
                                </div>
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <div class="col-lg-5 col-md-5">
                            <div class="form-group">
                                <label for="${data.fieldRecord.name}" class="col-lg-3 col-md-3 control-label">${data.fieldRecord.inchinese}：<c:if test="${data.fieldRecord.nulldisable}"><span style="color: red">*</span></c:if></label>
                                <div class="col-lg-9 col-md-9">
                                    <input type="text" class="form-control" id="${data.fieldRecord.name}" name="${data.fieldRecord.name}">
                                </div>
                            </div>
                        </div>
                    </c:otherwise>
                </c:choose>
                </div>
            </c:otherwise>
        </c:choose>
    </c:forEach>
    <c:if test="${fn:length(fieldRecords)%2!= 0}">
        </div>
    </c:if>
</form>
<script>
    function changeValue(currentObj, obj){
        var value = "";
        $("#"+ currentObj + " option:selected").each(function() {
            value += $(this).val() + ",";
        });
        if(value != ""){
            value = "," + value;
        }
        $("#"+ obj).val(value);
    };
    //级联操作
    function chageEnumSelectBoxValue(obj) {
        var childSelectId = $(obj).attr("ifcascadeid")
        $("[selfid='"+childSelectId+"']").val(0);
        $("[selfid='"+childSelectId+"']").children("[resoptionid]").css("display","none");
        $("[selfid='"+childSelectId+"']").children("[resoptionid='"+$(obj).val()+"']").css("display","block");
    };
</script>